#include<iostream>
#include<cstring>
using namespace std;
const int MX = 1e5 + 10;

int big[MX];

struct edge {
    int x, y, pre;
}e[MX];
int elen = 0, last[MX];

void ins(int x, int y) {
    e[++elen] = {x, y, last[x]};
    last[x] = elen;
}

int dfs(int x) {
    if(big[x])  return big[x];
    int ans = x;
    for(int k=last[x]; k; k=e[k].pre) {
        int y = e[k].y;
        int res = dfs(y);
        ans = ans > res ? ans : res;
    }
    big[x] = ans;
    return ans;
}

int main() {
    memset(last, 0, sizeof(last));
    memset(big, 0, sizeof(big));
    int n, m, x, y;
    cin >> n >> m;
    while(m--) {
        cin >> x >> y;
        ins(x, y);
    }
    for(int i=1; i<=n; i++) {
        if(!big[i]) dfs(i);
    }
    for(int i=1; i<=n; i++) {
        cout << big[i] << " ";
    }

    return 0;
} 